import { createStore, Store, useStore as useVuexStore } from 'vuex';
import { IRootState, IStoreType } from './type';
import { getToken as getCookiesToken } from '@/utils/cookies';
import router from '@/router';
import sessionCache from '@/utils/sessionCache';

const store = createStore<IRootState>({
  state: {
    token: ''
  },
  mutations: {},
  actions: {},
  modules: {}
});
/* 实现调用store有类型的功能 */
export function useStore(): Store<IStoreType> {
  return useVuexStore();
}
export const setupStore = () => {
  store.commit('changeToken', getCookiesToken());
};
export default store;
